import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// import userRouter from './modules/userCenter'
// import contentManageRouter from './modules/contentManage'
// import dataBoardRouter from './modules/dataBoard'
import rightsManageRouter from './modules/rightsManage'
// import activityManageRouter from './modules/activityManage'
// import commodityManageRouter from './modules/commodityManage'
// import channelManage from './modules/channelManage'
// import riseCup from './modules/riseCup'
// import dataReportManageRouter from './modules/dataReportManage'
// import advertisingManageRouter from './modules/advertisingManage'
// import teacherManageRouter from './modules/teacherManage'
// import userLabelManageRouter from './modules/userLabelManage'
// import campManageRouter from './modules/campManage'

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/sys/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    meta: {
      title: '首页',
      icon: 'icon-a-shouyeweixuan2x',
      activeIcon: 'icon-shouyexuanzhong'
    },
    children: [
      {
        path: 'dashboard',
        name: 'welcome',
        component: () => import('@/views/dashboard/index'),
        meta: {
          title: '欢迎页',
          pname: 'Dashboard',
          affix: true,
          breadcrumb: false
        }
      }
    ]
  }
]
/**
 * asyncRoutes
 * 需要根据用户角色动态加载的路由
 */
export const asyncRoutes = [
  // dataBoardRouter,
  // userRouter,
  // activityManageRouter,
  // contentManageRouter,
  // campManageRouter,
  // commodityManageRouter,
  // userLabelManageRouter,
  // riseCup,
  rightsManageRouter,
  { path: '*', redirect: '/', hidden: true }
]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
